Control of blood glucose induced by meals for type-1 diabetics using an adaptive backstepping algorithm

In this study, an adaptive backstepping method is proposed to regulate the blood glucose induced by meals for type-1 diabetic patients. The backstepping controller is used to control the blood glucose level and an adaptive algorithm is utilized to compensate for the blood glucose induced by meals. Moreover, the effectiveness of the proposed method is evaluated by comparing results in two different case studies: in the presence of actuator faults and the loss of control input for a short while during treatment. Effects of unannounced meals three times a day are investigated for a nominal patient in every case. It is argued that adaptive backstepping is the preferred control method in either case. The Lyapunov theory is used to prove the stability of the proposed method. Obtained results, indicated that the adaptive backstepping controller is stable, and the desired level of glucose concentration is being tracked efficiently.

www.nature.com/scientificreports/ require a set of rules based on advanced knowledge of the system or problem 20,21 . An adaptive control scheme is proposed in 22 , in which the controller is adjusted according to the changes in the system's behavior. The backstepping method, firstly introduced in 23 for nonlinear dynamical systems, is among the popular controller methods. It has a recursive design procedure and proved to be highly applicable to control blood glucose 24,25 , yet flexible to be used along with other methods, especially with adaptive control 26,27 . To bring adaptive control into the picture, the Lyapunov theory [28][29][30] , is the key to determining the adaptive rule. But, to control the blood glucose of T1D using the backstepping algorithm, there is still a gap in the literature that if it is advantageable to apply the adaptive control as well, to compensate for the uncertain effect of meals. There are various approaches to deal with the uncertainties of the dynamics of the system. To name a few, one technique is to use a neural network 31 , while the other one is adaptive control or a combination of both 32 . Compared to backstepping, adaptive backstepping can afford uncertainties of the model, while it might get out of control using the backstepping method. Therefore, adaptive backstepping is more reliable, especially in the presence of uncertainties, which can be seen in real-world applications. To the best of our knowledge, there is no investigation on a comparison between the efficiency of backstepping and adaptive backstepping methods to control T1D with an uncertain disturbance of meals. Furthermore, our proposed adaptive backstepping algorithm is robust in the presence of actuator faults and loss of control input for a short time, compared with the previous research on this subject in the literature.
In this paper, based on the Bergman minimal model 33 , two protocols are proposed such that blood glucose concentration tracks exponentially desired trajectories; one is achieved from backstepping and the other from adaptive backstepping. The effect of the meals, three times a day, has been considered in our analysis. Then, we claim a comparison of which method has the priority to have a better performance to control the blood glucose level of type 1 diabetic patients. Furthermore, to bring more strength to our argument, the performance of backstepping and adaptive backstepping methods are analyzed in two different case studies; in the first case study, the controllers are examined in the presence of actuator faults. In the second one, the controllers are analyzed to whether they hold their normal performance even if they confront an extremely low amount of gain affecting the input for a short while during treatment. It is concluded that under every circumstance, adaptive backstepping has the advantage.
The rest of this paper is organized as follows: the widely-used Bergman minimal model is introduced in "Mathematical model of type-1 diabetes". Next, the desired function of glucose concentration is defined in "Control algorithm", after which the analyses of backstepping and adaptive backstepping to achieve the final protocols are presented in "Backstepping method" and "Adapting backstepping method" respectively. This is followed by our investigation into two different case studies in "Numerical simulation". In the end, numerical  www.nature.com/scientificreports/ evaluation with the emphasis on comparison of the aforementioned methods, as well as case studies, are given in "Case study 1: actuator faults" and "Case study 2: controller failure for a short while".

Mathematical model of type-1 diabetes
The dynamics model of the blood glucose-insulin system is generally non-linear. A review study about different dynamical models can be found in 34 . The most commonly used mathematical model for the blood glucoseinsulin system known as Bergman minimal model was introduced in 1980 33 . In comparison with other models, the main advantage of the Bergman minimal model is its simplicity, where the relation of input and output is regulated with the minimum possible parameters, without further involvement of biological complexity. The dynamic equations of the system are as follows 35-38 : where G(t) is the glucose concentration in the blood plasma in mg/dl , X(t) is the interstitial insulin in 1/min and I(t) is the insulin concentration in the blood plasma in µU/ml (or µIU/ml ), G b and I b are the basal levels of glucose and insulin respectively, n is the time constant for insulin disappearance, p 1 , p 2 and p 3 are the insulinindependent constant rate of glucose uptake in muscles and liver, the rate for the decrease in tissue glucose uptake ability, and the insulin-dependent increase in glucose uptake ability in tissue per unit of insulin concentration above the basal level. The control input u(t) in µU/(ml/min) denotes the insulin injection rate, and D(t) shows the glucose taken from meals which are uncertain in measure as a disturbance. The parameter D(t) is defined by the following decaying exponential function 35 : where A and B are two positive constants. The parameter values of the model (1) for a type-1 diabetic patient are represented in Table 1 13,35 .

Remark 1
Note that for the unit of I(t) , and consequently the input u(t) , we use µU/ml (or µIU/ml ), where U ( IU ) stands for Units (International Units). However, in the International System of Units (SI), a mass-based ( pmol/L ) unit is used instead, yet the conversion rate is still under discussion. So, we proceed with the conventional form of the unit. For more information about the conversion rate, readers are referred to 39 .

Remark 2
As people usually eat more at lunch, parameters A and B in Eq. (2) are chosen such that the lunch is taken more quantitatively than dinner and the dinner is taken more than breakfast. The values of these parameters are represented in Table 2.

Control algorithm
First, a time-varying desired trajectory G d (t) is introduced as the reference signal for the glucose concentration G(t) to be tracked. The signal is defined as G d (t) = G ∞ + (G 0 − G ∞ )exp(−t/τ ) so that it decreases exponentially from the initial value G 0 to the set final value G ∞ = 100 with the time constant τ = 100 min.
(1) The insulin-independent constant rate of glucose uptake 0 1/min The decrease rate in tissue glucose uptake ability 0.0142 1/min The insulin-dependent increase in glucose uptake 1.5 × 10 −5 ml/μU/min www.nature.com/scientificreports/ Consider the error between the actual output and the reference defined as: From this point forward, x 1 , x 2 , x 3 , and x 1d are used instead of the parameters G(t) , X(t) , I(t) , and G d (t) respectively. Also, the notation of time (t) is removed for convenience.
Backstepping method. In this section, the goal is to converge the error signal e 1 to zero exponentially. The step by step designed protocol is as follows.
First step. Firstly, a positive definite Lyapunov function candidate is defined as V 1 = 1 2 e 2 1 . If its time derivative i.e., V 1 = e 1ė1 , is negative definite, it means e 1 is converging exponentially to zero. Hence the following stable error dynamics is chosen: where k 1 is a positive constant. Therefore, ė 1 from Eq. (4) can be applied into V 1 and consequently: It can be concluded that e 1 is converging exponentially to zero. Also, Eq. (4), can be written as: Now, ẋ 1 can be replaced from Eq. (1) into Eq. (6): The x 2 obtained from the above equation is the desired x 2 for the next step and it is denoted with x 2d . Therefore, we have: Note that as D is unknown, we are not allowed to bring it to the controller.
Second step. In the next step, the error signal for the actual value of the second state and its desired value is defined as e 2 = x 2 − x 2d . Accordingly, the second Lyapunov function candidate is defined as V 2 = 1 2 e 2 2 . The same scenario for achieving x 2d is applied to obtain x 3d . First, the desired error dynamics is selected as follows: where k 2 is a positive constant. Based on Eq. (9) we have ė 2 = −k 2 e 2 , and substituting it in the derivative of V 2 , leads to: Therefore, the derivative of the Lyapunov function candidate V 2 is obtained as a negative definite function. Consequently, e 2 would be converging to zero exponentially. Equation (9) can be written as follows: Substituting the corresponding value of ẋ 2 from Eq. (1) into Eq. (11), yields: And now, x 3 obtained from Eq. (12) is the desired one: Third step. In the last step, the error signal e 3 = x 3 − x 3d can be calculated and its Lyapunov function candidate is chosen as V 3 = 1 2 e 2 3 accordingly. Similar to the previous steps, assuming the following stable error dynamics for e 3 : where k 3 is a positive constant. This error dynamics leads to the following negative definite function for V 3 : Therefore, the exponential convergence of e 3 to zero can be concluded. To proceed towards this goal, Eq. (14) can be written as: where u is the input. Therefore, the input u can be achieved from Eq. (17) as: By selecting positive gains for k i (i : 1 → 3) , the control input obtained in Eq. (18) can lead e 1 to converge to zero exponentially, as a result, Adaptive backstepping method. In this section, an adaptive rule is designed to compensate for the disturbances of glucose taken from meals. A step-by-step procedure can be used until the desired input is acquired.
First step. In the first step, the Lyapunov function candidate is chosen as V 1 = 1 2 e 2 1 , which its derivative can be obtained as: Applying the corresponding value of ẋ 1 from Eq. (1)  where the term − De 1 will be canceled in the next step.
Second step. In this step, the next Lyapunov function candidate is chosen as: The time derivative of Eq. (23) can be written as: The corresponding value of ẋ 2 can be replaced from Eq. (1) into Eq. (24) and it yields to: Now, the desired value of x 3 is chosen as: Also, the following disturbance estimation equation is considered as an adaptive rule. where the derivative of V 2 is negative semi-definite in the next step the error signal e 3 is brought into the picture.
Third step. In the last step, V 3 is defined as V 3 = V 2 + 1 2 e 2 3 , which its time derivative is obtained as: By replacing the corresponding value of ẋ 3 from Eq. (1) into Eq. (29), we have: As can be seen, by choosing positive gains for k i (i : 1 → 3) , V 3 would be a negative semi-definite function. Regarding the reference signal x 1d is an exponentially decreasing function, hence it is globally bounded, so is e 1 . Moreover, ẋ 1d , x 1 , and D are also globally bounded. So, the global boundedness of x 2d is concluded, and consequently, e 2 is globally bounded. Furthermore, ẍ 1d , x 2 and ˙ D are also globally bounded, which yields to the global boundedness of x 3d and as a result, e 3 is globally bounded. Hence, the function V 3 is globally bounded as t → ∞ and V 3 is uniformly continuous (in other words V 3 is bounded). Then by Barbalat Lemma 28 , V 3 → 0 as t → ∞ . As a result, e 1 → 0 as t → ∞ , and x 1 → x 1d is achieved. A schematic of how the proposed control algorithm works is demonstrated in Fig. 2, where BGC stands for blood glucose concentration. The input is insulin injection rate, while the output is blood glucose level. It should be noted using continuous glucose monitoring (CGM), the states x 1 and x 2 can be measured, while the state x 3 can be estimated in real time 40,41 .

Numerical simulation
In this section, we represent numerical simulations of a type-1 diabetic patient under the Bergman minimal model and designed inputs in Eq. (18) and Eq. (31). For this purpose, we use the values of nominal parameters shown in Table 1. The simulations are investigated in a 24 h analysis, starting from fasting glucose level (no food taken for at least 8 h) at 6 A.M. The meals are taken at 8 A.M. as breakfast, 2 P.M. as lunch, and 8 P.M. as dinner. The effects of foods are placed somehow in which the lunch meal amount is more than dinner while dinner is more than breakfast. For type-1 diabetic patients, the fasting level of glucose is higher than 126 mg/dl 3 . So, we www.nature.com/scientificreports/ should set the initial condition G 0 higher than this level. The initial conditions are as follows: G(t 0 ) = 150 mg/ dl, X(t 0 ) = 0 1/min, and I(t 0 ) = 100 μU/ml. The gains are chosen as k 1 = 0.43 , k 2 = 0.46 , k 3 = 0.62 , analogous for both methods, with δ = 0.001 as the adaptive rule gain. The blood glucose level for a nominal patient under the control algorithm is depicted in Fig. 3. In Fig. 3, there are three colored zones divided by their safety level for type-1 diabetic patients. the zones are classified into the safe zone, warning zone, and dangerous zone. The area above 180 mg/dl (hyperglycemia) and below 70 mg/ dl (hypoglycemia) are labeled as dangerous zone, between 130 mg/dl and 180 mg/dl as the warning zone, and between 70 mg/dl and 130 mg/dl is the safe zone.
It can be easily seen that without treatment, the blood glucose level rises to a dangerous level, which proves that insulin for type-1 is not required for the control, but for survival 3 . Furthermore, regarding the efficiency of backstepping and adaptive backstepping methods, backstepping has been performed mostly in warning zone, even touching dangerous zone after lunch and dinner meals are taken. While, adaptive backstepping has shown a satisfying control performance as it keeps the glucose level in the safe zone, even during mealtime. Using the adaptive backstepping technique, a lunch meal with its huge influence could only increase blood glucose from 100 mg/dl to almost 112 mg/dl.
In Fig. 4, the graph of inputs is represented for comparison of backstepping and adaptive backstepping algorithms. In the beginning, as the fasting blood glucose rate was assumed to be matched with uncontrolled type-1 diabetes, the inputs confront jumps in insulin rate to compensate for high blood glucose levels as soon as possible. The insulin injection amounts are within reasonable ranges as almost 40 μU/ml is required during lunch for adaptive backstepping. The more insulin injected, the more decreasing blood glucose level could be, yet backstepping performance is not rewarding with a lesser insulin rate. Arguably, we do not have limits to use more   www.nature.com/scientificreports/ insulin dosage within practicable range, especially when it is humans' lives under discussion. Having the same controller gains, backstepping failed to apply more insulin amounts to show a better, yet necessary performance. In Fig. 5 the estimation of blood glucose induced by meals as a disturbance is demonstrated. Figure 5 indicates how well-ordered the proposed disturbance estimation is comparatively following its actual value. The adaptive backstepping advantage is relied on how efficiently the adaptive rule works.
In the last step, the graph shown in Fig. 6 represented the effectiveness of the adaptive backstepping algorithm to control the blood glucose level of the nominal patients with different initial conditions. Starting from even the harshest initial condition, with blood glucose level at 320 mg/dl, the safe zone is gradually obtained only 75 min after breakfast is eaten.

Case study 1: actuator faults
It is not deniable that the actuators may become obsolete after a while and show signs of faults in their performance. But the controller should be designed in advance such that it is robust towards actuator faults. In this section, the performance of backstepping and adaptive backstepping methods are compared under such conditions. To implement this purpose, multiplicative and additive actuator faults are applied to the controller in the form of: where ϕ(t) indicates the additive actuator fault and ρ(t) is the multiplicative actuator fault, such that 0 < ρ(t) ≤ 1 . Actuator faults are applied as harshly as possible; therefore, it would be a challenging task for the proposed algorithm. Towards this goal, the parameters are set as follows: ρ(t) = 0.01 + 0.99exp(−0.1t) and ϕ(t) = 0.1(1 − exp(−0.1t)).  www.nature.com/scientificreports/ Remark 3 Although it is not very realistic to design the actuator fault this much more severe, the faultier it is, the more robust the proposed algorithm can be claimed.

Remark 4
The additive fault, evident from its name, is a kind of fault added to the channel of control input separately. While, multiplicative fault steps on the normal value of input as a time-dependent gain, the more ρ(t) closed to zero, the faultier, and consequently weaker, the input becomes 42 .
The blood glucose level in the presence of actuator faults under the control algorithm is demonstrated in Fig. 7.
In Fig. 7, it is again obvious that the adaptive backstepping algorithm can control blood glucose even under such harsh conditions of actuator faults. However, the backstepping algorithm failed as the blood glucose level surged towards almost 250 mg/dl, while it was around 200 mg/dl without actuator faults after lunch was taken. On the contrary, for adaptive backstepping, the glucose level peaks at 120 mg/dl and 113 mg/dl, with and without actuator faults, respectively.
Insulin injection in the presence of actuator faults under the control algorithm is displayed in Fig. 8.
In Fig. 8, the graph of control inputs is given to indicate that the value of the input has remained in a reasonable range. Even the gains of the system to keep the adaptive backstepping algorithm well-performed, are still the same as without actuator faults. The difference can be seen in Fig. 9, as the disturbance estimation transcends its actual value and still can keep adaptive backstepping working properly.
In Fig. 9, compared to Fig. 5, where the disturbance estimation tracked its true value almost accurately, the parameter Doverestimated parameter D, especially around meal time. This is due to the existence of actuator fault, which are considered to be more severe and far from reality to evaluate the robustness of the controller. The faultier the actuator, the more robust the proposed algorithm can be claimed.   www.nature.com/scientificreports/ While the disturbance is overestimated due to an actuator fault, the controller tries to correct the faulty input effect by estimating the disturbance. As shown in Fig. 7, blood glucose levels return to the safe zone, but despite the high fault of the actuator, ideal answers can not be expected.

Case study 2: controller failure for a short while
As discussed before, insulin is required for the survival of type-1 diabetic patients. But what happens if the controller almost fails to work for a short while. The algorithm should be examined to the extent that if such a condition happens, it would not culminate in disaster for patients. To investigate this case study, control inputs are designed as follows: where, between 10 A.M. and 12 P. M., a very low amount of gain is multiplied by the input value. The efficiency of the adaptive backstepping algorithm is concluded one more time, compared to backstepping, to control blood glucose concentration.
In Fig. 10, the graph of blood glucose levels is presented where adaptive backstepping still holds the advantageable place. Noticeably, the appropriate reaction of adaptive backstepping to this condition is gentler while quicker. Adaptive backstepping jumps from almost 100 mg/dl to 130 mg/dl and comes back to its normal trend in only 15 min. However, backstepping increases from almost 130 mg/dl to 175 mg/dl, and it takes more than 1 h   www.nature.com/scientificreports/ to get back to its previous state. The considerable fact is that, during this process, adaptive backstepping remains in the safe zone, while backstepping takes steps nearer to the dangerous zone. In Figs. 11 and 12, the graph of inputs and disturbance estimation under this case study are depicted, respectively.
In Fig. 11, a small amount of deviation is seen at the start of this 2-h-period. The range of inputs almost stands the same as the former ones, though the gains are not alike. The gains are k 1 = 0.45 , k 2 = 0.45 , and k 3 = 1.5 similar for both methods, with δ = 0.007 as the adaptive rule gain.

Conclusion
Based on the Bergman Minimal model of glucose-insulin level of type-1 diabetics, the adaptive backstepping method had been proposed and compared with the backstepping algorithm. The effects of the meal taken three times a day had been considered in the model. The effectiveness of the adaptive backstepping method had excelled over that of the backstepping algorithm. Moreover, to indicate that adaptive backstepping is more robust in different conditions compared to backstepping, two case studies were investigated. One in the presence of the actuator faults and the other in the presence of an extremely low amount of gain to act on input for a short while. The efficiency of the proposed algorithm had been analyzed using numerical comparison results. All situations confirmed that adaptive backstepping had been much more promising than the backstepping method to control the blood glucose level of type-1 diabetic patients.

Data availability
No datasets were generated or analysed during the current study.